/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.cs.account.GalContact;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.Provisioning.GalResult;
/*    */ import com.zimbra.cs.account.Provisioning.Result;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.gal.GalOp;
/*    */ import com.zimbra.cs.service.mail.ToXML;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class CheckGalConfig
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 44 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/*    */     
/* 46 */     Element q = request.getOptionalElement("query");
/* 47 */     String query = null;
/* 48 */     long limit = 0L;
/* 49 */     if (q != null) {
/* 50 */       query = q.getText();
/* 51 */       limit = q.getAttributeLong("limit", 10L);
/*    */     }
/*    */     
/* 54 */     Element action = request.getOptionalElement("action");
/* 55 */     GalOp galOp = GalOp.search;
/* 56 */     if (action != null) {
/* 57 */       galOp = GalOp.fromString(action.getText());
/*    */     }
/* 59 */     Map attrs = AdminService.getAttrs(request, true);
/*    */     
/* 61 */     Element response = zsc.createElement(AdminConstants.CHECK_GAL_CONFIG_RESPONSE);
/* 62 */     Provisioning.Result r = Provisioning.getInstance().checkGalConfig(attrs, query, (int)limit, galOp);
/*    */     
/*    */ 
/* 65 */     response.addElement("code").addText(r.getCode());
/* 66 */     String message = r.getMessage();
/* 67 */     if (message != null) {
/* 68 */       response.addElement("message").addText(message);
/*    */     }
/* 70 */     if ((r instanceof Provisioning.GalResult)) {
/* 71 */       List<GalContact> contacts = ((Provisioning.GalResult)r).getContacts();
/* 72 */       if (contacts != null) {
/* 73 */         for (GalContact contact : contacts) {
/* 74 */           ToXML.encodeGalContact(response, contact);
/*    */         }
/*    */       }
/*    */     }
/* 78 */     return response;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 83 */     notes.add("Do not need any right, all admins are allowed.");
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/CheckGalConfig.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */